﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="ChiTietDeThi.aspx.cs" Inherits="Admin_DeThi_ChiTietDeThi" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">

    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#themcauhoi").click(function () {
                $("#fCauHoi").dialog("open");
                return false;
            });
            $("#fCauHoi").dialog({
                autoOpen: false,
                position:["center",50],
                modal: true,
                minHeight: 100,
                minWidth: 620
            });

            $("#ddltenloai").change(function () {
                loadCauhoi();
            });
            $("#ddltenmon").change(function () {
                loadCauhoi();
            });
            $("#ddldokho").change(function () {
                loadCauhoi();
            });
        });
        function loadCauhoi() {
            var maloai = $("#ddltenloai").val();
            var mamon = $("#ddltenmon").val();
            var dokho = $("#ddldokho").val();
            $.ajax({
                type: "POST",
                url: "../Ajax/DeThiAjax.aspx",
                data: { Methods: "DanhSachCauHoi", MaLoai: maloai, MaMon: mamon, MaDoKho: dokho },
                success: function (result) {
                    $("#fCauHoi .result").find("tbody").html(result);
                },
                error: function () {

                }
            });
        }
        function themcauhoi(MaCauHoi) {
            var MaDe = $("#txtMaDe").val();
            $.ajax({
                type: "POST",
                url: "../Ajax/DeThiAjax.aspx",
                data: { Methods: "ThemChiTietDeThi", MaCauHoi: MaCauHoi, MaDeThi: MaDe },
                success: function (result) {
                    result = $.parseJSON(result);
                    if (result.Status == 'Success') {
                        __doPostBack('ctl00$MainContent$refresh', '');
                    } else {
                        jAlert(result.Mess, "Thong bao");
                    }
                },
                error: function () {

                }
            });
        }
        function xoaCauHoi(MaCH) {
            var MaDe = $("#txtMaDe").val();
            $.ajax({
                type: "POST",
                url: "../Ajax/DeThiAjax.aspx",
                data: { Methods: "XoaChiTietDeThi", MaCauHoi: MaCH, MaDeThi: MaDe },
                success: function (result) {
                    result = $.parseJSON(result);
                    if (result.Status == 'Success') {
                        __doPostBack('ctl00$MainContent$refresh', '');
                    } else {
                        jAlert(result.Mess, "Thong bao");
                    }
                },
                error: function () {

                }
            });
            return false;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:HiddenField ID="txtMaDe" ClientIDMode="Static" runat="server" />
    <h3 class="head-title">
        <asp:Label ID="lblTenDe" runat="server" Text="Label"></asp:Label>
    </h3>
    <p>Thang điểm: <asp:Label ID="lblThangDiem" runat="server" Text="Label"></asp:Label></p>
    <p>Chú thích: <asp:Label ID="lblChuThich" runat="server" Text="Label"></asp:Label></p>

    <p>
        <button type="submit" class="btn btn-default" id="themcauhoi">Thêm Câu hỏi</button>
    </p>

    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:LinkButton ID="refresh" runat="server" OnClick="refresh_Click"></asp:LinkButton>
            <asp:GridView ID="GridView1" CssClass="table table-bordered" runat="server" AutoGenerateColumns="False" Width="100%">
                <Columns>
                    <asp:BoundField DataField="MaCH" HeaderText="Mã câu hỏi" />
                    <asp:BoundField DataField="NoiDungCH" HeaderText="Nội dung" />
                    <asp:TemplateField HeaderText="Tác Vụ">
                        <ItemTemplate>
                            <a href="javascript:void()" onclick="return xoaCauHoi(<%#Eval("MaCH") %>)" class="btn btn-default m-l-3" title="Xóa">
                                <i class="fa fa-trash-o"></i>
                            </a>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </ContentTemplate>
    </asp:UpdatePanel>

    <div id="fCauHoi" title="Thêm câu hỏi">
        <table>
            <tr>
                <td>Tên loại:</td>
                <td>
                    <asp:DropDownList ID="ddltenloai" runat="server" ClientIDMode="Static">
                    </asp:DropDownList>
                </td>
                <td>Tên môn:</td>
                <td><asp:DropDownList ID="ddltenmon" runat="server" ClientIDMode="Static">
                    </asp:DropDownList></td>
                <td>Độ khó:</td>
                <td><asp:DropDownList ID="ddldokho" runat="server" ClientIDMode="Static">
                    </asp:DropDownList></td>
            </tr>
        </table>
        <div style="width:100%; height:400px; overflow-y: auto">
            <table class="result table table-bordered">
                <thead>
                    <tr>
                        <th style="width:50px">Mã</th>
                        <th style="width:500px">Câu hỏi</th>
                        <th style="width:70px">Tác vụ</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
    </div>
</asp:Content>